<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>تفاصيل الاتفاقية</title>

<!------------------------------ajax---------------------------->
<!-- <script type="text/javascript"  src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script> 
    <script type="text/javascript"  src="http://malsup.github.com/jquery.form.js"></script> -->
	
<!---------------------for autocomplete--------------->
	<script type="text/javascript" src="<?php echo base_url('assets/js/jquery-1.11.0.min.js');?>" ></script>
	<script type="text/javascript" src="<?php echo base_url('assets/js/jquery-ui-1.10.4/js/jquery-ui-1.10.4.min.js');?>" ></script>
	<link href="<?php echo base_url("assets/css/jquery-ui.css")?>" rel="stylesheet" type="text/css" />
<!---------------------for form css ----------------------->
	<link href="<?php echo base_url("assets/css/pure.css")?>" rel="stylesheet" type="text/css" />
<!---------------------for form validation ----------------------->
<script type="text/javascript" src="<?php echo base_url('assets/js/jquery.validate.js');?>" ></script>
<!---------------------for form mask input ----------------------->
<script type="text/javascript" src="<?php echo base_url('assets/js/jquery.mask.min.js');?>" ></script>


</head>
<body>
<?php
include_once('header.php');


// ----- populate $liste_des_activites array for autocomplete ----- //
echo form_open_multipart( base_url('/convention_crt/update_convention').'/'.$result[0]->id_convetion ); 

if($result[0]->is_regularise==1){
  $regule='نعم';
	}else{
		$regule='لا';
	}
?>


<form id="convention_form" class="pure-form pure-form-stacked"  method="POST" action="<?php echo base_url('/convention_crt/update_convention').'/'.$result[0]->id_convetion;?>">
    
        <legend>رقم الاتفاقية: <?php echo('<strong>'.$result[0]->numero.'</strong>');?></legend>

        <div class="pure-g">
            <div class="pure-u-1 pure-u-md-1-3" style="width: 30%">
                <label for="fournisseur">اسم المورد </label>
				<label><?php echo($result[0]->nom);?></label>
            </div>

            <div class="pure-u-1 pure-u-md-1-3 " style="width: 30%">
                <label for="article">التاريخ </label>
                <label><?php echo($result[0]->date);?></label>
            </div>

          
			
			

		
			
			<div class="pure-u-1 pure-u-md-1-3 "  style="width: 30%">
                <label for="numero"> تسوية </label>
				<label><?php echo($regule);?></label>
                
            </div>
			<div class="pure-u-1 pure-u-md-1-3 "  style="width: 30%">
                <label for="numero"> المبلغ </label>
				<label  style="display: inline-block" class="ltr"><?php echo(number_format($result[0]->montant, 2, ',', ' '));?></label>
                
            </div>
			 </div>
			     <?php
			//	echo($lettre.'<br>');
				
  $goupe=$this->session->userdata('user_group'); //access it
if($goupe=="admin"){
echo ('<input type="submit" id="ajouter" value="تحديث"  class="pure-button-disabled pure-button-primary" />
	 <a href="'.base_url('/convention_crt/').'" class="pure-button pure-button-primary" >خروج</a>
	 <a href="'.base_url('/convention_crt/imprimer_convention_regularise').'/'.$result[0]->id_convetion.'" class="pure-button pure-button-primary" >طباعة</a>
	 ');
}else{
	echo ('<a href="#" class="pure-button-disabled pure-button-primary">تحديث</a>
	 <a href="'.base_url('/convention_crt/').'" class="pure-button pure-button-primary" >خروج</a>
	 <a href="'.base_url('/convention_crt/imprimer_convention_regularise').'/'.$result[0]->id_convetion.'" class="pure-button pure-button-primary" >طباعة</a>
	 ');
}
?>
	
		</form>

<?php
if($result[0]->is_regularise==1){
	foreach($tab_bcs as $info){
		echo('
<form id="convention_form" class="pure-form pure-form-stacked" method="POST" action="'.base_url('/convention_crt/update_convention').'/'.$result[0]->id_convetion.'">
        <div class="pure-g">
            <div class="pure-u-1 pure-u-md-1-3">
                <label for="fournisseur">رقم الوصل </label>
				<label>'.$info[0]->numero.'</label>
            </div>

            <div class="pure-u-1 pure-u-md-1-3" >
                <label for="article">التاريخ </label>
                <label>'.$info[0]->date.'</label>
            </div>

            <div class="pure-u-1 pure-u-md-1-3" >
                <label for="numero"> رقم الاتزام </label>
				<label>'.$info[0]->num_engagement.'</label>
                
            </div>
			
			 <div class="pure-u-1 pure-u-md-1-3 ">
                <label for="numero"> المبلغ</label>
				<label  style="display: inline-block" class="ltr">'.number_format($info[0]->montant, 2, ',', ' ').'</label>
                
            </div>
			</div>
		
		</form>
		
			.'
			 );
	}
	
} 
?>
<div id="erreur" style="text-align: center; background-color: red; width: 50%; margin-right: 25%;">
	<?PHP
	if($msg){
		echo 'عملية التحديث لم تتم بنجاح </br>';
		if(array_key_exists('date',$msg)){
			echo 'حقل ادخال التاريخ خاطئ </br>';
		}
		if(array_key_exists('delai_realisation',$msg)){
			echo 'حقل ادخال مهلة الانجاز  خاطئ </br>';
		}
		if(array_key_exists('delai_payement',$msg)){
			echo 'حقل ادخال مهلة التخليص خاطئ </br>';
		}
		
	}
	
	
	?>
</div>			

</body>

<script>

$('#date').bind('mouseup keyup focusout focus mousemove',function() {
    $('span.error-phone').hide();
	$(this).css('background-color','pink');
    var inputVal = $(this).val();
    var characterReg = /^(\d{4}-\d{2}-\d{2})$/;
    if(!characterReg.test(inputVal)) {
        $(this).after('<span class="error-phone" style="color:red;" >حقل غير مطابق للشكل العام </span>');
    }else{
		$(this).css('background-color','#FFFFFF');
	}
});

$('#delai_realisation').bind('mouseup keyup focusout focus mousemove',function() {
    $('span.error-phone').hide();
	$(this).css('background-color','pink');
    var inputVal = $(this).val();
    var characterReg = /^(\d+)$/;
    if(!characterReg.test(inputVal)) {
        $(this).after('<span class="error-phone" style="color:red;" >حقل غير مطابق للشكل العام </span>');
    }else{
		$(this).css('background-color','#FFFFFF');
	}
});

$('#delai_payement').bind('mouseup keyup focusout focus mousemove',function() {
    $('span.error-phone').hide();
	$(this).css('background-color','pink');
    var inputVal = $(this).val();
    var characterReg = /^(\d+)$/;
    if(!characterReg.test(inputVal)) {
        $(this).after('<span class="error-phone" style="color:red;" >حقل غير مطابق للشكل العام </span>');
    }else{
		$(this).css('background-color','#FFFFFF');
	}
});
//---

</script>

</html>